package com.sxjh.controller.cb;

import com.sxjh.common.BaseController;
import com.sxjh.config.Authorization;
import com.sxjh.common.Result;
import com.sxjh.entity.param.ChemicalYaResult;
import com.sxjh.entity.param.Finance9Param;
import com.sxjh.entity.param.FinanceList3Param;
import com.sxjh.entity.param.MethylAlcoholListParam;
import com.sxjh.entity.result.*;
import com.sxjh.service.FinanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 化工辅料
 */
@RestController
@RequestMapping("/chemical")
@Api(tags = "化工辅料")
public class Finance9Controller extends BaseController {

  @Autowired
  private FinanceService financeService;

  @ApiOperation("二氧化碳")
  @GetMapping("/ey-ht")
  @Authorization("cb.chemical.ey-ht")
  Result<List<MethylAlcoholListResult>> list2(@Validated Finance9Param param) {
    MethylAlcoholListParam param1 = new MethylAlcoholListParam();
    param1.setStartDate(param.getStartDate().atStartOfDay());
    param1.setEndDate(param.getEndDate().atTime(23, 59, 59));
    param1.setMaterialId(94);
    List<MethylAlcoholListResult> list = financeService.list(param1);
    return ok(list);
  }

  @ApiOperation("盐酸")
  @GetMapping("ys")
  @Authorization("cb.chemical.ys")
  Result<List<MethylAlcoholListResult>> list5(@Validated Finance9Param param) {
    MethylAlcoholListParam param1 = new MethylAlcoholListParam();
    param1.setStartDate(param.getStartDate().atStartOfDay());
    param1.setEndDate(param.getEndDate().atTime(23, 59, 59));
    param1.setMaterialId(88);
    List<MethylAlcoholListResult> list = financeService.list(param1);
    return ok(list);
  }

  @ApiOperation("中质洗油")
  @GetMapping("zz-xy")
  @Authorization("cb.chemical.zz-xy")
  Result<List<MethylAlcoholListResult>> list6(@Validated Finance9Param param) {
    MethylAlcoholListParam param1 = new MethylAlcoholListParam();
    param1.setStartDate(param.getStartDate().atStartOfDay());
    param1.setEndDate(param.getEndDate().atTime(23, 59, 59));
    param1.setMaterialId(92);
    List<MethylAlcoholListResult> list = financeService.list(param1);
    return ok(list);
  }

  @ApiOperation("氢氧化钾")
  @GetMapping("/qy-hj")
  @Authorization("cb.chemical.qy-hj")
  Result<List<Finance9List3Result>> list3(@Validated Finance9Param param) {
    FinanceList3Param param1 = new FinanceList3Param();
    param1.setStartDate(param.getStartDate().atStartOfDay());
    param1.setEndDate(param.getEndDate().atTime(23, 59, 59));
    List<Finance9List3Result> list = financeService.list5(param1);
    return ok(list);
  }

  @ApiOperation("硫酸")
  @GetMapping("/ls")
  @Authorization("cb.chemical.ls")
  Result<List<FinanceList4Result>> list4(@Validated Finance9Param param) {
    FinanceList3Param param1 = new FinanceList3Param();
    param1.setStartDate(param.getStartDate().atStartOfDay());
    param1.setEndDate(param.getEndDate().atTime(23, 59, 59));
    List<FinanceList4Result> list = financeService.list6(param1);
    return ok(list);
  }

  @ApiOperation("硫酸明细")
  @GetMapping("/ls-dt")
  @Authorization("cb.chemical.ls-dt")
  Result<List<Finance9ListDtResult>> list4Dt(@Validated FinanceList3Param param) {
    return ok(financeService.list6Dt(param));
  }

  @ApiOperation("纯碱")
  @GetMapping("/cj")
  @Authorization("cb.chemical.cj")
  Result<List<Finance9ListResult>> list(@Validated Finance9Param param) {
    FinanceList3Param param1 = new FinanceList3Param();
    param1.setStartDate(param.getStartDate().atStartOfDay());
    param1.setEndDate(param.getEndDate().atTime(23, 59, 59));
    return ok(financeService.list23(param1));
  }

  @ApiOperation("纯碱明细")
  @GetMapping("/cj-dt")
  @Authorization("cb.chemical.cj.dt")
  Result<List<Finance9ListDtResult>> listDt(@Validated FinanceList3Param param) {
    return ok(financeService.list23Dt(param));
  }

  @ApiOperation("液碱")
  @GetMapping("/yj")
  @Authorization("cb.chemical.yj")
  Result<List<Finance9List7Result>> list7(@Validated Finance9Param param) {
    FinanceList3Param param1 = new FinanceList3Param();
    param1.setStartDate(param.getStartDate().atStartOfDay());
    param1.setEndDate(param.getEndDate().atTime(23, 59, 59));
    return ok(financeService.list7(param1));
  }

  @ApiOperation("聚合硫酸铁")
  @GetMapping("/jh-lst")
  @Authorization("cb.chemical.jh-lst")
  Result<List<Finance9List9Result>> list8(@Validated Finance9Param param) {
    FinanceList3Param param1 = new FinanceList3Param();
    param1.setStartDate(param.getStartDate().atStartOfDay());
    param1.setEndDate(param.getEndDate().atTime(23, 59, 59));
    return ok(financeService.list8(param1));
  }

  /**
   * 未将每吨包装重量算在内，待后续优化
   */
  @ApiOperation("聚合硫酸铁明细")
  @GetMapping("/jh-lst-dt")
  @Authorization("cb.chemical.jh-lst-dt")
  Result<List<Finance9ListDtResult>> list8Dt(@Validated FinanceList3Param param) {
    return ok(financeService.list8Dt(param));
  }

  @ApiOperation("液氨")
  @GetMapping("/ya")
  @Authorization("cb.chemical.ya")
  Result<List<ChemicalYaResult>> list9(@Validated Finance9Param param) {
    FinanceList3Param param1 = new FinanceList3Param();
    param1.setStartDate(param.getStartDate().atStartOfDay());
    param1.setEndDate(param.getEndDate().atTime(23, 59, 59));
    return ok(financeService.list19(param1));
  }

}